﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartHotel.BLL;
using SmartHotel.DAL;
using SmartHotel.Model;

namespace SmartHotel.WebAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoomInfoController : ControllerBase
    {
        public RoomInfoController(RoomInfoBLL roomInfoBLL)
        {
            RoomInfoBLL = roomInfoBLL;
        }

        public RoomInfoBLL RoomInfoBLL { get; }


        [HttpPost]
        public int AddRoom(RoomInfo roomInfo)
        {

            return RoomInfoBLL.AddRoom(roomInfo);
        }
        /// <summary>
        /// 根据id查房间号
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public RoomInfo GetRoomInfoById(int id)
        {
            return RoomInfoBLL.GetRoomInfoById(id);
        }
        [HttpDelete]
        public int DeleteRoom(int id)
        {
            return RoomInfoBLL.DeleteRoom(id);
        }

        [HttpPut]
        public int Update(RoomInfo roomInfo)
        {
            return RoomInfoBLL.Update(roomInfo);
        }
        /// <summary>
        /// 根据房型id查找房型对应的所有房间
        /// </summary>
        /// <param name="roomTypeId"></param>
        /// <returns></returns>
        [HttpGet]
        public List<RoomInfo> GetRooms(int roomTypeId)
        {
            return RoomInfoBLL.GetRooms(roomTypeId);
        }
    }
}
